<template>
	<view class="container">
		<view class="pagetop">
			<view class="pagetop-head">
				<view class="pagetop-head-l">
					<view class="page-icon">
						<image src="../../static/ic_logo2.png" mode="widthFix"></image>
					</view>
					<view class="page-title">{{hospitalinfo.name}}</view>
				</view>
				<view class="pagetop-head-r">{{hospitalinfo.tags}}</view>
			</view>
			<view class="pagetop-swiper">
				<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
					<swiper-item>
						<view class="swiper-item" v-for="(item,index) in bannerlist" :key="index" @click="bannerdetail(item.id)">
							<image :src="item.image" mode=""></image>
						</view>
					</swiper-item>
				</swiper>
			</view>
			<view class="pagetop-fenlei">
				<view class="page-item" v-if="keshilist1 != ''" @click="keshidetail(keshilist1.id)">
					<view class="page-item-icon" >
						<image src="../../static/ic_ya1.png" mode="widthFix"></image>
					</view>
					<view class="page-item-text">{{keshilist1.name}}</view>
				</view>
				<view class="page-item" style="margin-left: 28rpx;" v-if="keshilist2 != ''"  @click="keshidetail1(keshilist2.id)">
					<view class="page-item-icon">
						<image src="../../static/ic_ya2.png" mode="widthFix"></image>
					</view>
					<view class="page-item-text">{{keshilist2.name}}</view>
				</view>
				<view class="page-item" style="margin-left: 28rpx;"  @click="keshidetailall">
					<view class="page-item-icon">
						<image src="../../static/ic_ya3.png" mode="widthFix"></image>
					</view>
					<view class="page-item-text">全部分类</view>
				</view>
			</view>
		</view>
		<view class="pagebottom">
			<view class="pagebottom-item">
				<view class="pagebottom-item-title">医院地址</view>
				<view class="pagebottom-item-con">
					<view class="pagebottom-item-l">{{hospitalinfo.address}}</view>
					<view class="pagebottom-item-r" @click="openlocation">
						<image src="../../static/ic_daohang.png" mode="widthFix"></image>
					</view>
				</view>
			</view>
			<view class="pagebottom-item">
				<view class="pagebottom-item-title">联系电话</view>
				<view class="pagebottom-item-con">
					<view class="pagebottom-item-l">{{hospitalinfo.mobile}}</view>
					<view class="pagebottom-item-r" @click="calltel">
						<image src="../../static/ic_call.png" mode="widthFix"></image>
					</view>
				</view>
			</view>
			<view class="pagebottom-item">
				<view class="pagebottom-item-title">医院介绍</view>
				<view class="pagebottom-item-def">
					{{hospitalinfo.bio}}
				</view>
				<!-- <view class="reducemore">
					更多介绍
				</view> -->
			</view>
		</view>
		<Patient-footer-bar :selected="0"></Patient-footer-bar>
	</view>
</template>

<script>
	import app from '../../App.vue'
	export default {
		data() {
			return {
				title: 'Hello',
				hospitalinfo:'',
				keshilist1:{},
				keshilist2:{},
				bannerlist:[]
			}
		},
		onLoad() {
			this.gethospitalinfo()
			this.getfenlei()
			this.getbanner()
		},
		onShow() {
			this.getlogin()
		},
		methods: {
			getlogin(){
				uni.showLoading({
					mask:true,
					success() {
						let token = uni.getStorageSync('token')
						// console.log(token)
						if(token){
							uni.hideLoading()
						}else{
							uni.hideLoading()
							uni.redirectTo({
								url:'../login/login'
							})
						}
					}
				})
			},
			gethospitalinfo(){
				let that = this,
				data = {
					type:'1,2,3,4,5'
				}
				app.post('api/common/getConfig',data).then(res=>{
					if(res.code == 1){
						that.hospitalinfo = res.data
					}
				})
			},
			getfenlei(){
				let that = this,
				data = {
					keyword:'',
					limit:''
				}
				app.post('api/department/lis',data).then(res=>{
					if(res.code == 1){
						that.keshilist1 = res.data[0]
						that.keshilist2 = res.data[1]
						console.log(that.keshilist1.name)
					}
				})
			},
			getbanner(){
				let that = this,
				data = {
				}
				app.post('/api/banner/getBanner',data).then(res=>{
					if(res.code == 1){
						that.bannerlist = res.data
					}
				})
			},
			bannerdetail(id){
				uni.showLoading({
					title:'加载中',
					success() {
						setTimeout(function(){
							uni.hideLoading()
							uni.navigateTo({
								url:'/pages/leader/leaderinfo?id='+id
							})
						},1300)
					}
				})
			},
			keshidetail(id){
				uni.showLoading({
					title:'加载中',
					success() {
						setTimeout(function(){
							uni.hideLoading()
							uni.navigateTo({
								url:'/pages/keshi/detail?id='+id
							})
						},1300)
					}
				})
			},
			keshidetail1(id){
				uni.showLoading({
					title:'加载中',
					success() {
						setTimeout(function(){
							uni.hideLoading()
							uni.navigateTo({
								url:'/pages/keshi/detail?id='+id
							})
						},1300)
					}
				})
			},
			keshidetailall(){
				uni.showLoading({
					title:'加载中',
					success() {
						setTimeout(function(){
							uni.hideLoading()
							uni.redirectTo({
								url:'/pages/keshi/keshi'
							})
						},1300)
					}
				})
			},
			calltel(){
				uni.makePhoneCall({
					phoneNumber:this.hospitalinfo.mobile,
				})
			},
			openlocation(){
				uni.openLocation({
					latitude:Number(39.015731),
					longitude:Number(117.661352),
					// success(res) {
					// 	console.log(res)
					// },
					// fail(err) {
					// 	console.log(err)
					// }
				})
				
			}
		}
	}
</script>

<style>
	@import url("../../common/index.css");
</style>
